/**
 * @ author: 汪孟苹
 */
define(["jquery",
	"scprit/followup/app/workBench/workBenchAll.servers.js",
	"scprit/followup/app/workBench/workBenchAll.ui.js",
	"scprit/followup/app/workBench/workBenchAll.event.js"],
	function($,$workBenchServers,$workBenchUi,$workBenchEvent){
	var workBench = {};

	/**
	 * 请求统计数据成功后的回调函数
	 */
	var ajaxStatisCallBack = function(data){
		$workBenchUi.windowPtInit({
			id:"windowBottomStatistics",
			list: data
		});
		$workBenchUi.windowTopInit({
			id:"dashboardCardlist",
			list: data
		});
		$(".dashboard-add #addPatient").click($workBenchEvent.onAddPatientClick);
	}
	/**
	 * 请求队列成功后的回调函数
	 */
	var ajaxQueueCallBack = function(rows){
		$workBenchUi.selectQueueInit({
			id: "selectQueue",
			list: rows
		});
	}
	/**
	 * 请求今日门诊记录成功后的回调函数
	 */
	var ajaxPatientsOperateCallBack = function(rows){
		$workBenchUi.windowRightInit({
			id:"patientOperateListQuery",
			list:rows
		});
		$("#patientOperateListQuery .baby-done").data({"value":rows});
		$("#patientOperateListQuery .baby-done").click($workBenchEvent.onBabyClick);
	}

	workBench.init = function(){
		$workBenchServers.ajaxStatis(ajaxStatisCallBack);
		$workBenchServers.ajaxQueue(ajaxQueueCallBack);
		var params1 = {
			"page":1,
			"rows":11,
			"flag":"0",
			"schemeBusiType":2  // 全部：随访 + 门诊
		};
		$workBenchServers.ajaxPatientsOperate(params1,ajaxPatientsOperateCallBack);	// 今日门诊
		var rows;
		if( document.body.offsetWidth < 992 ){
			rows = 2;
		}else if( document.body.offsetWidth <1200 ){
			rows = 3;
		}else{
			rows = 4;
		}
		var params2 = {
			"page":1,
			"rows":4*rows,
			"flag":"2",  //"0":窗口期;"2":全部
			"systemType":"02"
		};
		$workBenchServers.ajaxPatientsQueue(params2,$workBenchEvent.ajaxPatientsQueueCallBack);	// 窗口期计划随访患者
	}; 

	return workBench;
});